package com.aaa.controller.scl;

import com.aaa.entity.LayData;
import com.aaa.entity.MyPage;
import com.aaa.entity.fpa.TjMessage;
import com.aaa.entity.scl.SclRecord;
import com.aaa.service.scl.SclRecordService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * (SclRecord)表控制层
 *
 * @author makejava
 * @since 2022-10-27 19:11:05
 */
@RestController
@RequestMapping("sclRecord")
public class SclRecordController {
    /**
     * 服务对象
     */
    @Autowired
    private SclRecordService sclRecordService;

    /**
     * 分页查询所有题目
     * @param myPage
     * @param sclRecord
     * @return
     */
    @RequestMapping("queryAllRecord")
    @ResponseBody
    public LayData queryAllRecord(MyPage myPage, SclRecord sclRecord){
        List<SclRecord> sclRecords = sclRecordService.queryAllRecord(myPage, sclRecord);
        return new LayData(sclRecords);
    }

    /**
     * 模糊查询
     * @param myPage
     * @param sclRecord
     * @return
     */
    @RequestMapping("querysclRecordAll")
    @ResponseBody
    public LayData querysclRecordAll(MyPage myPage, SclRecord sclRecord){
        PageInfo pageInfo =sclRecordService.querySclRecordAll(myPage, sclRecord);
        System.out.println("sclrecord里的pageInfo = " + pageInfo.toString());
        return new LayData(pageInfo);
    }
    /**
     * 详情信息
     * @param id
     * @param myPage
     * @return
     */
    @GetMapping("{id}")
    public LayData getDetailData(@PathVariable Integer id, MyPage myPage){
        return new LayData(sclRecordService.getDetailMsg(myPage,id));
    }

    /**
     *查询电话号码
     * @param record
     * @return
     */
    @GetMapping("checkrecord")
    public LayData checkUser(SclRecord record){
        return new LayData(sclRecordService.checkrecord(record));
    }

    /**
     * 将记录添加到数据库
     * @param record
     * @return
     */
    @PostMapping("addrecord")
    public LayData addrecord(SclRecord record){
        return new LayData(sclRecordService.insertRecord(record));
    }

    /**
     * 统计页面数据
     * @param myPage
     * @param tjMessage
     * @return
     */
    @RequestMapping ("tj")
    public LayData getTongji2(MyPage myPage, TjMessage tjMessage){
        PageInfo tj = sclRecordService.getTj(myPage, tjMessage);
        System.out.println("tj = " + tj.toString());
        return new LayData(tj);
    }


}

